package wechat.base.snd.test

import org.junit.Ignore
import org.junit.Test
import wechat.base.snd.WCApplication

class MessageTest {
	private static String CALLBACK_SERVER_URL = "http://58.247.87.218:8090"
	private static String MOBILD_CALLBACK_SERVER_URL = "http://mobileangularui.com/demo"
	String callbackurl
	
	@Test
	@Ignore
	def void dslWebPageTest(){
		
		WCApplicationFactory4Test::testApp=>[
			createNews()=>[
				callbackurl = generateUrl("redirect","rockweixinid","rock","11111", "测试任务", "测试任务描述")
				withItem('新消息')=>[
					picurl = CALLBACK_SERVER_URL+"/sample.jpg"
					url= callbackurl
				]
				withItem('任务名称:测试任务\n\r任务描述:测试任务描述')=>[
					picurl = CALLBACK_SERVER_URL+"/smallsample.jpg"
					url= callbackurl
				]
				send2Users(newArrayList('@all'))
			]
		]
	}
	
	@Test
	@Ignore
	def void dslSendMessageTest(){
		WCApplicationFactory4Test::testApp=>[
			createNews()=>[
				withItem('新消息')=>[
					picurl = CALLBACK_SERVER_URL+"/sample.jpg"
					url= generateUrl("","","11111", "测试任务", "测试任务描述")
				]
				withItem('任务名称:测试任务\n\r任务描述:测试任务描述')=>[
					picurl = CALLBACK_SERVER_URL+"/smallsample.jpg"
					url= generateUrl("","","11111", "测试任务", "测试任务描述")
				]
				send2Users(newArrayList('rock20110501'))
			]
		]
	}
	@Test
	@Ignore
	def void dslSendMessageDirect3MobildUITest(){
		WCApplicationFactory4Test::testApp=>[
			createNews()=>[
				withItem('新消息')=>[
					picurl = CALLBACK_SERVER_URL+"/sample.jpg"
					url= generateUrl("","","11111", "测试任务", "测试任务描述")
				]
				withItem('任务名称:测试任务\n\r任务描述:测试任务描述')=>[
					picurl = CALLBACK_SERVER_URL+"/smallsample.jpg"
					url= MOBILD_CALLBACK_SERVER_URL
				]
				send2Users(newArrayList('ztiange-'))
			]
		]
	}
	@Test
	@Ignore
	def void dslUploadTmpFileTest(){
		WCApplicationFactory4Test::testApp=>[
			uploadTmpFile("sample.jpg")=>[
			println("\nmedia_id is "+media_id)	
			]
		]
	}
	@Test
	@Ignore
	def void dslSendMpNewsTest(){
		WCApplicationFactory4Test::testApp=>[
			createMPNews()=>[
				withItem('新消息')=>[
					thumb_media_id = "1lbyj8sNRzr-Y4g9yLR_yg05jCum73B3QJiSSa3jPpDygbs03JrdOuscuVxeuT-QMNZLIZLZTi5-p3AN1Ngnb2A"
					content ="test"
				]
				send2Users(newArrayList('ztiange-'))
			]
		]
	}
//	
	def generateUrl(String who, String id, String task_id,String project_name, String task_desc) {
			 CALLBACK_SERVER_URL+"/"+"taskdetails"+"?who="+who +"&assigneeid="+id
				+"&taskid="+task_id
				+"&projectname="+project_name
				+"&taskdesc="+task_desc
	}
	def generateUrl(String request,String who, String id, String task_id,String project_name, String task_desc) {
			 CALLBACK_SERVER_URL+"/"+request+"?who="+who +"&assigneeid="+id
				+"&taskid="+task_id
				+"&projectname="+project_name
				+"&taskdesc="+task_desc
	}
}

class WCApplicationFactory4Test{
//	private static WCApplication testApp = new WCApplication('wx8f929502ae3cd538','5QS5Gpk175kEX9kPEXI8JWRfbteEkZuArlgG_JZaWy4NtA0uKmIvl-9754U-ynkn','2')
//	private static WCApplication testApp = new WCApplication('wxb98818984c2fa92f','bHLdtbkdeYb29ZH8n_SVHzhNd-J0kI1lftOnJAgo44xrFx9twVfTrK4wy0CdXIAU','3')
	private static WCApplication testApp = new WCApplication('wx89f88f98210ded84','1Cxp8BjM7cJpduFPZm9a-YbA1xbSMzSStu8LrSjtGMiW84odNnc3yVoTMEq40aqZ','0')//lanmon
// Customer App
//	private static WCApplication customerApp = new WCApplication('wx8f929502ae3cd538','9gBRoP6X3wAyzKEbJqgd39K3_t5yQK2b-PC-Z5TkNVktbTO9B-3Jxc73Dl2vNDq0','3') //Customer Trail
	private static WCApplication customerApp = new WCApplication('wx59b4783059880985','-2stl0g0Tfz7CvU4r_45_NVkOD_AhDy8UHST_vZ4Z17u4zIG28lf1vX8ZupfIlVw','0') //yunduo
	def static getTestApp(){
//		testApp
		customerApp
	}
	def static getCustomerApp(){
		customerApp
	}
}